home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import com.extensibility.util.Debug;
- import javax.swing.event.ChangeListener;
- import javax.swing.event.EventListenerList;
-
- public class DeclRef implements QualifiedName {
- String qName;
- private String prefix;
- private String ncName;
- private boolean isUsingNamespace = false;
- private SchemaIntf schema;
- Class targetClass;
- SourceIntf source;
- EventListenerList listenerList = new EventListenerList();
- DeclRefChangeEvent changeEvent = new DeclRefChangeEvent(this);
-
- public DeclRef(String var1, Class var2) {
- int var3 = var1.indexOf(58);
- if (var3 >= 0) {
- this.prefix = var1.substring(0, var3);
- this.ncName = var1.substring(var3 + 1);
- } else {
- this.ncName = var1;
- }
-
- this.qName = var1;
- this.targetClass = var2;
- }
-
- public final boolean isBound() {
- return this.source != null;
- }
-
- protected final void checkBound() {
- Debug.assert(this.source != null, "this reference has been released or is not yet bound");
- }
-
- public BaseDeclaration getTargetDecl() {
- return (BaseDeclaration)this.getTargetObj();
- }
-
- public ElementDeclaration getTargetElement() {
- return (ElementDeclaration)this.getTargetDecl();
- }
-
- public AttributeDeclaration getTargetAttribute() {
- return (AttributeDeclaration)this.getTargetDecl();
- }
-
- public InternalPEDeclaration getTargetIPE() {
- return (InternalPEDeclaration)this.getTargetDecl();
- }
-
- public Object getTargetObj() {
- this.checkBound();
- SchemaIntf var1 = this.getTargetSchema();
- BaseDeclaration var2 = null;
- if (var1 != null) {
- var2 = var1.getNamedDeclaration(this.getNameInTarget(), this.targetClass);
- }
-
- return var2;
- }
-
- public String getNameInTarget() {
- String var1 = this.isUsingNamespace ? this.ncName : this.qName;
- return var1;
- }
-
- public String getName() {
- return this.qName;
- }
-
- public String getPrefix() {
- return this.prefix;
- }
-
- public String getNCName() {
- return this.ncName;
- }
-
- public boolean isQualified() {
- return this.prefix != null;
- }
-
- public void setName(String var1) {
- String var2 = this.qName;
- this.qName = var1;
- int var3 = var1.indexOf(58);
- if (var3 >= 0) {
- this.prefix = var1.substring(0, var3);
- this.ncName = var1.substring(var3 + 1);
- if (this.schema != null) {
- this.isUsingNamespace = this.schema.isSupported(Class.forName("com.extensibility.xml.NamespaceDeclaration"));
- }
- } else {
- this.prefix = null;
- this.isUsingNamespace = false;
- this.ncName = var1;
- }
-
- this.fireChangeEvent(var2);
- }
-
- public void setPrefix(String var1) {
- String var2 = this.qName;
- this.prefix = var1;
- this.qName = this.prefix != null ? String.valueOf(String.valueOf(this.prefix).concat(String.valueOf(':'))).concat(String.valueOf(this.ncName)) : this.ncName;
- if (this.schema != null) {
- this.isUsingNamespace = this.schema != null ? this.schema.isSupported(Class.forName("com.extensibility.xml.NamespaceDeclaration")) : false;
- }
-
- this.fireChangeEvent(var2);
- }
-
- public Class getTargetClass() {
- return this.targetClass;
- }
-
- public SchemaIntf getSchema() {
- return this.schema;
- }
-
- public void release() {
- if (this.schema != null) {
- this.schema.releaseDeclRef(this);
- }
-
- this.source = null;
- this.schema = null;
- }
-
- public void bind(SchemaIntf var1, SourceIntf var2) {
- if (this.source != null) {
- this.release();
- }
-
- this.source = var2;
- this.schema = var1;
- this.isUsingNamespace = this.prefix != null && var1.isSupported(Class.forName("com.extensibility.xml.NamespaceDeclaration"));
- if (var1 != null) {
- var1.bindDeclRef(this);
- }
-
- }
-
- public boolean equals(Object var1) {
- if (var1 instanceof DeclRef) {
- return this.equals((DeclRef)var1);
- } else {
- return var1 instanceof String ? this.equals((String)var1) : false;
- }
- }
-
- public String toString() {
- return this.qName;
- }
-
- public boolean equals(DeclRef var1) {
- return this.targetClass == var1.targetClass && this.qName.equals(var1.qName);
- }
-
- public boolean equals(String var1) {
- return var1.equals(this.qName);
- }
-
- public int hashCode() {
- int var1 = this.targetClass.hashCode() ^ this.qName.hashCode();
- return var1;
- }
-
- protected SchemaIntf getTargetSchema() {
- SchemaIntf var1 = null;
- if (this.schema != null) {
- if (this.isUsingNamespace) {
- try {
- var1 = this.schema.getNamedSchema(this.prefix);
- } catch (Exception var3) {
- }
- } else {
- var1 = this.schema;
- }
- }
-
- return var1;
- }
-
- public void addChangeListener(ChangeListener var1) {
- this.listenerList.add(Class.forName("javax.swing.event.ChangeListener"), var1);
- }
-
- public void removeChangeListener(ChangeListener var1) {
- this.listenerList.remove(Class.forName("javax.swing.event.ChangeListener"), var1);
- }
-
- public void fireChangeEvent(String var1) {
- this.changeEvent.setOldQName(var1);
- Object[] var2 = this.listenerList.getListenerList();
-
- for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
- if (var2[var3] == Class.forName("javax.swing.event.ChangeListener")) {
- ((ChangeListener)var2[var3 + 1]).stateChanged(this.changeEvent);
- }
- }
-
- }
- }
-